import { MessageBox, Message } from 'element-ui'

function confirm(message: string, title: string, options: Record<string, any>) {
  return MessageBox.confirm(message, title, options)
}

confirm.success = function (message: string, title: string = '') {
  return confirm(message, title, {
    type: 'success',
  })
}

confirm.error = function (message: string, title: string = '') {
  return confirm(message, title, {
    type: 'error',
  })
}

confirm.warning = function (message: string, title: string = '') {
  return confirm(message, title, {
    type: 'warning',
  })
}

confirm.info = function (message: string, title: string = '') {
  return confirm(message, title, {
    type: 'info',
  })
}

function message(text: string) {
  
  if (!text) {
    return
  }
  
  Message(text)
  
}

message.success = function (text: string) {
  
  if (!text) {
    return
  }
  
  Message({
    message: text,
    type: 'success',
    customClass: 'shb-el-message--success',
  })
}

message.error = function (text: string | undefined) {
  
  if (!text) {
    return
  }
  
  Message({
    message: text,
    type: 'error',
    customClass: 'shb-el-message--error',
  })
  
}

message.warning = function (text: string) {
  
  if (!text) {
    return
  }
  
  Message({
    message: text,
    type: 'warning',
    customClass: 'shb-el-message--warning',
  })
  
}

message.info = function (text: string) {
  Message({
    message: text,
    type: 'info',
    customClass: 'shb-el-message--info',
  })
}

export {
  confirm,
  message
}

export default {
  confirm,
  message
}